<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<%@ include file="/web/header.jsp"%>
<title>用户登陆</title>
</head>
<body>
	<fieldset id="">
		<legend style="font-size: 25px; color: black">员工信息维护</legend>
		<div class="layui-form">
			<div class="layui-field-box">
				<!-- <form class="layui-form" > -->
				<div class="layui-form-item">
					<label class="layui-form-label">员工编号</label>
					<div class="layui-input-inline">
						<input type="text" name="codeEmp" placeholder="请输入员工编号"
							autocomplete="off" class="layui-input">
					</div>
					<label class="layui-form-label">项目编号</label>
					<div class="layui-input-inline">
						<input type="text" name="codePro" placeholder="请输入项目编号"
							autocomplete="off" class="layui-input">
					</div>

					<input type="button" id="selc" value="搜索" lay-submit
						lay-filter="search" class="layui-btn" />
						 <input onclick="openAdd()" type="button" value="添加" class="layui-btn" id="add1" />
				</div>

			</div>
						<input type = "hidden" name = "action" value="page" >
						<input type = "hidden" name = "pageIndex" value="1" >
						<input type = "hidden" name = "pageLimit" value="10" >
						
		</div>
		<table style="" class=" layui-table">
			<thead>
				<tr>
					<th style="width: 15%; text-align: left;">ID</th>
					<th style="width: 15%; text-align: left;">员工编号</th>
					<th style="width: 15%; text-align: left;">项目编号</th>
					<th style="width: 15%; text-align: left;">项目绩效</th>
					<th style="width: 15%; text-align: left;">操作</th>
				</tr>
			</thead>
			<tbody id="tbody">

			</tbody>
		</table>
		<div id="pageInfoScore" style="text-align:right;padding-right:30px"></div>
	</fieldset>
	<script type="text/javascript">
		formSubmit("/ScoreServlet","submit(search)","json",function(data){
			console.log(data)
			var cur = $("input[name='pageIndex']").val();
			var limit = $("input[name='pageLimit']").val();
			setPageInfo("pageInfoScore",data.count,cur,limit,function(obj,first){
				$("input[name='pageIndex']").val(obj.curr);
				$("input[name='pageLimit']").val(obj.limit);
				if(!first){
					refresh();
				}
			})
			
			var html ="";
			$.each(data.list,function(i,dom){
				console.log(dom)
				var codeEmpl = dom.codeEmp?dom.codeEmp:'';
				var codeProj = dom.codePro?dom.codePro:'';
				var codeScore = dom.score?dom.score:'';
				var d={i:i+1,codeEmp:codeEmpl,codePro:codeProj,score:codeScore}
				html += getlaytpl("#tradd",d);
			})
			$("#tbody").html(html);
			layer.msg("查询成功")
			
		})
		
		refresh();
		function refresh() {
			$("input[value='搜索']").click();
		}
		function openAdd(){
			openlayer("/web/page/score/add.jsp",refresh);
		}
		
		function del(codeEmp,codePro){
			openConfirm(function(){
				ajax("/ScoreServlet",{action:"del",codeEmp:codeEmp,codePro:codePro},"text",function(data){
					if(1==data){
						layer.msg("删除成功",refresh)
					}else{
						layer.msg("删除失败")
					}
				})
			})
		}
		function openUpd(codeEmp,codePro){
// 			console.log(1)
			openlayer("/web/page/score/upd.jsp?codeEmp="+codeEmp+"&codePro="+codePro,refresh)
		}
		
	</script>
	<script type="text/html" id= "tradd">
		<tr>
			<td>{{d.i}}</td>
			<td>{{d.codeEmp}}</td>
			<td>{{d.codePro}}</td>
			<td>{{d.score}}</td>
			<td><a href='javascript:del("{{d.codeEmp}}","{{d.codePro}}");' 
					class="layui-btn layui-btn-sm layui-btn-danger">
					<i class="layui-icon layui-icon-delete"></i>
					</a>&nbsp;&nbsp;
					<input type="button" onclick='openUpd("{{d.codeEmp}}","{{d.codePro}}")'
					 class="layui-btn layui-btn-sm" value="修改"/></td>
		</tr>
	</script>
	

	</body>
</html>
